
<?php 	$db		= &JFactory::getDBO();
		$user = & JFactory::getUser();
		$order_id = JRequest::GetVar('order_id');
		//var_dump(JURI::base());die;
			
		$mail = new JConfig();
		$from = $mail->mailfrom;
		$query = "SELECT * FROM #__users_extension WHERE id = ".$user->id;
		$db->setQuery($query);
		$user_info = $db->loadObject();
		
		
		$query = "SELECT order_date, order_finished, order_comment FROM #__pr_orders WHERE order_id = ".$order_id;
		$db->setQuery($query);
		$order_info = $db->loadObject();
		$order_text = str_pad($order_id,6,"0",STR_PAD_LEFT);
		?>
			<body style="font-family:Lucida Sans Unicode, Lucida Grande, sans-serif; ">


<table style="width:780px; margin:0px auto; padding:10px;" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><a style="background:url('templates/bookrengoring/img/logo.png') no-repeat; text-indent:-9999px; width:240px; height:53px; display:block; "><?php echo $mail->fromname ?></a></td>
  </tr>
  <tr>
  	<td colspan="1">
    	<table width="780px" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td style="background-color:#5D9ECA; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="2" >Faktura</td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px;" width="313">Faktura nummer:</td>
            <td width="467" style="color:#323232; font-size:12px; padding:1px;"><?php echo $order_text ?></td>
          </tr>
		  <tr>
            <td style="color:#323232; font-size:12px; padding:1px;" width="313">Bestil dato</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo strftime('%d-%m-%Y', strtotime($order_info->order_date)) ?></td>
          </tr>
		   
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px;" width="313">Udførelses dato:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo strftime('%d-%m-%Y %H:%M:%S', strtotime($order_info->order_finished)) ?></td>
          </tr>
		   
          <tr>
            <td style="background-color:#5D9ECA; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="2" >Kundeinformation</td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Firma/institution:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->company ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Kontaktperson:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user->name ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Adresse:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->address ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Postnr.:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->post ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">By:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->city ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Telefon/mobil:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->phone ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">CVR-nr.:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user_info->cvr ?></td>
          </tr>
          <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">E-mail:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $user->email ?></td>
          </tr>
		  <tr>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; ">Kommentar:</td>
            <td style="color:#323232; font-size:12px; padding:1px; width:30%; "><?php echo $order_info->order_comment ?></td>
          </tr>		 
       </table>
    </td>
  </tr>
  <tr>
  	<td style="border-bottom: 1px solid #5D9ECA;">
  		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
	            <td style="background-color:#5D9ECA; padding:1px; color:white; font-size:15px; font-weight:bold;" colspan="5" >Ordrelinier</td>
	        </tr>
			<tr>		       	
		       
		       	<td width="70" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Floor</td>
		       	<td width="400" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Navn værelse</td>
		       	<td width="60" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Kvalitet</td>
                <td width="100" style="color:#323232; font-size:11px; text-align:center; padding:1px; ">Pris (DKK)</td>
		    </tr>

		<?php 
			
			$db->setQuery("SELECT order_total FROM #__pr_orders WHERE order_id = ".$order_id);
			$order_total = $db->loadResult();
			$query = "SELECT cat.name AS catname, pp.name AS product_name, pt.name as ptype, pd.price
			FROM ((((#__pr_cart AS cart LEFT JOIN #__pr_productdetail AS pd ON cart.productdetail_id = pd.id)
			LEFT JOIN #__pr_product_category AS pc ON pd.product_category_id = pc.id)
			LEFT JOIN #__pr_producttype AS pt ON pt.id = pd.producttype_id)
			LEFT JOIN #__pr_product AS pp ON pc.product_id = pp.id)
			LEFT JOIN jos_pr_category AS cat ON cat.id = pc.category_id
			WHERE cart.order_id = ".$order_id;
			
			$query = $db->setQuery($query);
			$cart = $db->loadObjectList();
				
			foreach ($cart as $item) {
			//	$query = "SELECT number FROM #__pr_product WHERE id = ".$item->product_id;
			//	$query = $db->setQuery($query);
			//	$pro = $db->loadObject();
			?>
		  

			<tr>
		     
		       	<td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $item->catname; ?></td>
		       	<td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $item->product_name; ?></td>
		       	<td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $item->ptype; ?></td>
		       	<td style="color:#323232; font-size:11px; text-align:center; padding:1px; "><?php echo $item->price; ?> DKK</td>
		    </tr>
			<?php } ?>
		
          
        </table>
  	</td>
  </tr>
  <tr>
  	<td style="text-align: right; color:#323232; font-size:12px; padding:0px; padding:2px 43px 50px 0; font-weight: bold;">At betale: <?php echo $order_total ?> DKK</td>
  </tr>
  <tr>
  	<td style="background-color:#5D9ECA; padding:1px; ">
  		<p style="color:#FFF; font-size:13px; margin:0;">Øresundsvej 12A - 2300 København S • CVR-nr. : 33 57 41 18 • Tlf.: 81 75 33 43 • rengoring@servicegroup.dk</p> 
  		<p style="color:#FFF; font-size:13px; margin:0;">Mail: <a onmouseover="this.style.textDecoration = underline" onmouseout="this.style.textDecoration = none " style="display:inline; text-decoration: none; color:#FFF;" href="mailto:rengoring@servicegroup.dk">rengoring@servicegroup.dk</a> - CVR-nr. : 33 57 41 18</p>
  	
	</td>
  </tr>
</table>
</body>